package com.dingding.commonservice.core.city.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dingding.common.core.beans.City;
import com.dingding.common.core.exception.bussiness.BussinessException;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.commonservice.core.city.dao.ICityDao;
import com.dingding.commonservice.core.city.service.ICityService;
import com.dingding.facade.commonservice.common.dto.city.ResOpenCityDTO;
import com.dingding.facade.commonservice.common.dto.company.ReqServiceCity;

/**
 * 
 * @ClassName: CityServiceImpl 
 * @Description: 开通城市业务逻辑实现类
 * @author YHQ
 * @date 2016年12月1日 下午3:17:20
 * @since V2.5.7
 * 
 */
@Component("cityService")
public class CityServiceImpl implements ICityService{

	@Resource(name = "openCityDao")
	private ICityDao cityDao;
	
	/**
	 * 
	 * @Title: geOpenCityDTOs 
	 * @Description: 获取开通城市列表
	 * @author YHQ 
	 * @since V2.5.7
	 * @return List<ResOpenCityDTO>    返回类型
	 * 
	 */
	public List<ResOpenCityDTO> geOpenCityDTOs() {
		
		return cityDao.geCityDTOs();
	}

	/**
	 * 
	 * @Title: isServiceCity 
	 * @Description: 根据城市编号获取城市信息
	 * @param reqServiceCity 客户端请求参数
	 * @author YHQ 
	 * @since V2.5.7
	 * @return City  城市信息
	 * 
	 */
	@Override
	public City isServiceCity(ReqServiceCity reqServiceCity) {
		
		// 判断客户请求参数是否为空
		if(reqServiceCity == null || !ToolUtil.validateParam(reqServiceCity)){
			
			return null;
		}
		
		return cityDao.isServiceCity(reqServiceCity.getCityNo());
	}

	@Override
	public ResOpenCityDTO getOpenCityDTOByCityId(Integer cityId) throws BussinessException{
		
		return cityDao.getCityDTO(cityId);
	}

}
